home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / GRAPHICS / YAK_WAVE.ZIP / WAVE.ASM < prev    next >
Encoding:
Assembly Source File  |  1995-06-26  |  10.8 KB  |  202 lines

  1. ;---------------------------------------------------------------------------
  2. ; Diz is George Stark typing ....
  3. ;
  4. ; You see now another short but nice source code of me ...
  5. ; it is no new effect but I guess a really nice one and I have seen it
  6. ; the first time in an intro of a friend called Digisnap/FATAL! .. Now
  7. ; I had a lot of free time and I didn't know what I could do so I started
  8. ; coding this effect ..  and you see I managed it hehehe ..
  9. ;
  10. ; So ... I tried to comment the source and I did it really well but your
  11. ; problem could be the principle ... okay .. you have got a 3D plain
  12. ; ( I used a 40x40 field ) ... and now you take a sine function or something
  13. ; like this and change the y position (or Offset) of every point using the
  14. ; values ... and instead of a pixel you write a block .. and that's it !
  15. ; easy eh ? ... and don't blame me 'cause of using so many BIG tables
  16. ; ... everybody uses ASM for a great speed ... to use tables is more
  17. ; comfortable and faster than realtime calculating everything ... in an
  18. ; intro or demo for a competition it could be important but here it is
  19. ; not a problem .... for pre-calculating I have used TP .. slow but
  20. ; easy to program mathematical problems ... for questions ask me ...
  21. ; and if you got new ideas or use the source greet me and YAKUZA .. hehe
  22. ;
  23. ;                                              thx and bye .. cu l8er
  24. ;
  25. ;                                                George Stark/YAKUZA
  26. ;
  27. ;----------------------------------------------------------------------------
  28.  
  29. .model small                                             ; enough ...
  30. .stack 100h                                              ; too much ?!!?
  31. .386                                                     ; for greater
  32. .data                                                    ; opcodes ...
  33.                                   include kurve.tab
  34.                                   include thewave.tab
  35.                                   include abstand.tab
  36.                                   adder    dw 0
  37.                                   virtual  dw 0
  38.                                   copyrights db 'Code by GEORGE STARK/YAKUZA DS+HS , 07.06.1995',10,13,'$'
  39.                                   error    db 'Memory error ...',10,13,'$'
  40. .code
  41.  
  42.                           retrace proc near
  43.                                   push dx
  44.                                   push ax
  45.                                   mov dx,03DAh
  46.                                   mov ah,8
  47. active:                           in al,dx
  48.                               and al,ah
  49.                       je active
  50. test_again:                       in al,dx
  51.                               and al,ah
  52.                            jne test_again
  53.                                   pop ax
  54.                                   pop dx
  55.                                   retn
  56.                           retrace endp
  57.  
  58.                             block proc near
  59.                                   pusha
  60.                                   mov di,ds:[si]         ; screen offset
  61.                                   mov bx,ds:[si+2]       ; widht
  62.                                   mov cx,ds:[si+4]       ; height
  63.                                   inc cx
  64.                                   add di,dx              ; new_height
  65.                                   xor ax,ax
  66.                                   mov ax,dx
  67.                                   shr ax,7               ; div 128
  68.                                   add al,120             ; new color
  69. whole_block:                      push cx
  70.                                   mov cx,bx
  71.                                   push di
  72.                                   rep stosb              ; one line
  73.                                   pop di
  74.                                   add di,320             ; next line offset
  75.                                   pop cx
  76.                                   loop whole_block       ; all lines
  77.                                   popa
  78.                                   retn
  79.                             block endp
  80.  
  81.                     clear_virtual proc near
  82.                                   pusha
  83.                                   mov di,16000           ; di to offset 16000
  84.                                   mov cx,8000            ; 8000x4 bytes
  85.                                   xor eax,eax
  86.                                   rep stosd              ; clear memory
  87.                                   popa
  88.                                   retn
  89.                     clear_virtual endp
  90.  
  91.                      copy_virtual proc near
  92.                                   pusha                  ; flicker free
  93.                                   push es                ; deleting +
  94.                                   push ds                ; painting ..
  95.                                   mov ax,virtual
  96.                                   mov ds,ax              ; set ds to virtual
  97.                                   mov ax,0A000h
  98.                                   mov es,ax              ; es to 0A000h
  99.                                   mov di,16000
  100.                                   mov si,di
  101.                                   mov cx,8000
  102.                                   rep movsd              ; copy 8000x4 bytes
  103.                                   pop ds
  104.                                   pop es
  105.                                   popa
  106.                                   retn
  107.                      copy_virtual endp
  108.  
  109.                     change_colors proc near
  110.                                   pusha
  111.                                   mov dx,03c8h
  112.                                   mov al,1
  113.                                   out dx,al              ; color 1 first
  114.                                   inc dx
  115.                                   mov di,63              ; highest
  116.                                   xor si,si
  117.                                   mov cx,254             ; 254 colors
  118. all_colors:                       add si,24              ; using
  119.                                   cmp si,99              ; fix point
  120.                                   jbe color_part         ; arithmetics
  121.                                   dec di                 ; c=c+0.24
  122.                                   sub si,99
  123. color_part:                       mov ax,di
  124.                                   out dx,al
  125.                                   xor al,al
  126.                                   out dx,al
  127.                                   mov al,12
  128.                                   out dx,al
  129.                                   loop all_colors        ; I hope you
  130.                                   popa                   ; understand
  131.                                   retn
  132.                     change_colors endp
  133.  
  134. memory_error:                     mov ah,09h
  135.                                   mov dx,offset error
  136.                                   int 21h                ; Error message
  137.                                   mov ah,4Ch
  138.                                   int 21h                ; bye bye
  139.  
  140. start:                            mov dx,@data
  141.                                   mov ds,dx              ; init ds
  142.                                   mov ah,4Ah
  143.                                   mov bx,4000
  144.                                   int 21h                ; change memory size
  145.                                   jc memory_error        ; Error ..
  146.                                   mov ah,48h             ; lame machine !
  147.                                   mov bx,4000
  148.                                   int 21h                ; get memory
  149.                                   jc memory_error        ; äh .. lame !
  150.                                   mov virtual,ax         ; save VIRTUAL Seg.
  151.                                   mov es,ax              ; es to V-Seg
  152.                                   cld                    ; clear direction
  153.                                   mov al,2
  154.                                   out 21h,al             ; bye int 09h
  155.                                   mov ax,13h             ; flag ...
  156.                                   int 10h                ; initialize mode
  157.                                   call change_colors     ; ups ?!?!
  158.                                   xor bp,bp              ; internal pointer
  159. over_and_over:                    add bp,2               ; speed of moving
  160.                                   cmp bp,360             ; ( 2 steps )
  161.                                   jb it_is_okay
  162.                                   sub bp,360             ; table size
  163. it_is_okay:                       call clear_virtual     ; no idea ?!?!
  164.                                   mov cx,1600            ; many bytes eh ?
  165. for_cx_to_do:                     mov bx,cx
  166.                                   shl bx,1               ; *2
  167.                                   add bx,offset abstand  ; abstand + counter
  168.                                   mov dx,[bx]            ; entry ?
  169.                                   add dx,bp              ; entry + internal
  170.                                   cmp dx,360             ; table size
  171.                                   jb nothing_to_change
  172.                                   sub dx,360
  173. nothing_to_change:                mov di,offset kurve    ; wave itself
  174.                                   shl dx,1               ; *2
  175.                                   add di,dx
  176.                                   mov dx,ds:[di]         ; new height
  177.                                   imul si,cx,6           ; si=cx*6
  178.                                   add si,offset wave     ; great 386's hehe
  179.                                   call block             ; and show it ...
  180.                                   dec cx                 ; table of 40x40
  181.                                   cmp cx,0
  182.                                   ja for_cx_to_do        ; do it ...
  183.                                   call retrace           ; for same speed
  184.                                   call copy_virtual      ; show the wave
  185.                                   in al,60h
  186.                                   cmp al,1               ; ask keyb. port
  187.                                   jne over_and_over      ; ESC ?!?
  188.                                   mov al,0               ; welcome back
  189.                                   out 21h,al             ; int 09h
  190.                                   mov ax,03h             ; textmode 80x25
  191.                                   int 10h                ; color
  192.                                   mov ah,49h
  193.                                   int 21h                ; free memory
  194.                                   jc memory_error
  195.                                   mov ah,09h
  196.                                   mov dx,offset copyrights
  197.                                   int 21h
  198.                                   mov ah,4Ch
  199.                                   int 21h                ; and bye ...
  200. end start
  201.  
  202. ;                                                  bye GEORGE STARK/YAKUZA